//  头部返回
import Vue from 'vue'

Vue.directive('head-back', {
  bind: function (el, binding, vnode) {
    let handleBack = () => {
      window.history.length > 1
        ? vnode.context.$router.back()
        : vnode.context.$router.push('/')
    };
    el.addEventListener('click', function () {
      handleBack();
    });
  }
});
